package cn.snmp.mutual.nms;

public class SnmpTimeticks extends SnmpUnsignedInt
{
    public SnmpTimeticks(final long l) {
        super(l);
        this.Type = 67;
    }
    
    @Override
    int encode(final byte[] abyte0, final int i) throws ArrayIndexOutOfBoundsException {
        return ASNTypes.encodeUInt(abyte0, i, (int)this.numberValue, 67);
    }
    
    String fmt(final int i) {
        String s = String.valueOf(i);
        if (s.length() < 2) {
            s = "0" + s;
        }
        return s;
    }
    
    public String toShortString() {
        final StringBuffer stringbuffer = new StringBuffer();
        long l = this.numberValue;
        l /= 100L;
        final int i1 = (int)(l / 86400L);
        l %= 86400L;
        final int k = (int)(l / 3600L);
        l %= 3600L;
        final int j = (int)(l / 60L);
        final int m = (int)(l % 60L);
        if (i1 == 1) {
            stringbuffer.append("1d ");
        }
        else if (i1 != 0) {
            stringbuffer.append(i1 + "d ");
        }
        stringbuffer.append(this.fmt(k) + ":");
        stringbuffer.append(this.fmt(j) + ":");
        stringbuffer.append(this.fmt(m));
        return stringbuffer.toString();
    }
    
    @Override
    public String toString() {
        final StringBuffer stringbuffer = new StringBuffer();
        long l = this.numberValue;
        l /= 100L;
        final int i1 = (int)(l / 86400L);
        l %= 86400L;
        final int k = (int)(l / 3600L);
        l %= 3600L;
        final int j = (int)(l / 60L);
        final int m = (int)(l % 60L);
        if (i1 == 1) {
            stringbuffer.append("1 day, ");
        }
        else if (i1 != 0) {
            stringbuffer.append(i1 + " days, ");
        }
        stringbuffer.append(k + " hours, ");
        stringbuffer.append(j + " minutes, ");
        stringbuffer.append(m + " seconds. ");
        return stringbuffer.toString();
    }
    
    @Override
    public String toTagString() {
        return "TimeTicks : " + this.toString();
    }
}
